
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE proc [dbo].[createNewHotel]
(	
	@HotelName nvarchar (200),
	@Price money,
	@ProvinceID int,
	@RangeID int,	
	@ServiceID int,
	@TotalRoom int,
	@Images nvarchar (200),
	@Description nvarchar (2000),
	@Address1 nvarchar (200),
	@Email nvarchar (50),
	@Phone1 nvarchar (50),
	@Fax nvarchar (50),
	@Phone2 nvarchar (50),
	@Address2 nvarchar (200),
	@Address3 nvarchar (200),
	@InsertedID int output
)
as  
BEGIN
SET NOCOUNT ON;	
BEGIN TRAN
DECLARE	@errorCode INT        
SET @errorCode = 0
insert into Hotels 
(
	HotelName,
	Prices,
	ProvinceID,
	ServicesID,
	RangeID,
	TotalRoom,
	Images,
	[Description],
	Address1,
	Email,
	Phone1,
	Fax,
	Phone2,
	Address2,
	Address3
)
Values
(
	@HotelName,
	@Price,
	@ProvinceID,
	@RangeID,
	@ServiceID,
	@TotalRoom,
	@Images,
	@Description,
	@Address1,
	@Email,
	@Phone1,
	@Fax,	
	@Phone2,
	@Address2,
	@Address3
)
SELECT @InsertedID = SCOPE_IDENTITY()
	IF ( @@ERROR <> 0 ) 
	  BEGIN		                
		SET @errorCode = 1
		ROLLBACK
	  END
	COMMIT TRAN	
	RETURN @errorCode	
End
GO
